﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class user_FormComment : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSubmitComment_Click(object sender, EventArgs e)
    {

        int idProduct = Convert.ToInt32(Request.QueryString["ID"]);
        Comment objComment = new Comment();
        objComment.PdID = idProduct;
        if (Session["email"] != null && Session["password"]!=null)
        {
            String email = Session["email"].ToString();
            String pass = Session["password"].ToString();
            CustomerBus customerBus = new CustomerBus();
            objComment.CusID = (int)customerBus.getInfoCustomer(email,pass).Rows[0]["cus_id"];
        }
        objComment.CmTitle = txtTitle.Text;
        objComment.CmContent = txtContent.Text;
        objComment.CmStatus = true;
        CommentBus commentBus = new CommentBus();
        if (commentBus.AddComment(objComment))
        {
            resetTextBox();
        }

    }
    public void resetTextBox()
    {
        txtContent.Text = "";
        txtTitle.Text = "";
    }
}
